package com.axsoft.jobimp.types;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

public class UTF8 extends DataType {

	private String mString;
	
	public UTF8() {
		super(1);
	}
	
	public UTF8(final String pString) {
		super(1);
		setUTF8(pString);
	}
	
	public UTF8(final byte[] pData) {
		super(1);
		setBytes(pData);
	}
	
	public final String getString() {
		return mString;
	}
	
	public void setUTF8(final String pString) {
		mData = pString.getBytes(Charset.forName("UTF-8"));
		mString = pString;
	}
	
	public void setBytes(final byte[] pBytes) {
		mData = pBytes.clone();
		
		try {
			mString = new String(pBytes, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			mString = null;
		}
		
	}
	
}
